import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;
import java.util.ResourceBundle;

public class Demo13 {
    public static void main(String[] args) {
        String driver;
        String url;
        String user;
        String password;
        ResourceBundle resourceBundle=ResourceBundle.getBundle("jdbc");
        driver=resourceBundle.getString("driverClass");
        url=resourceBundle.getString("url");
        user=resourceBundle.getString("user");
        password=resourceBundle.getString("password");
        InputStream resourceAsStream=Demo13.class.getClassLoader().getResourceAsStream("jdbc.properties");
        Properties properties=new Properties();
        try {
      properties.load(resourceAsStream);
      driver=properties.getProperty("driverClass");
      url=properties.getProperty("url");
      user=properties.getProperty("user");
      password=properties.getProperty("password");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        try {
            Class.forName(driver);
            Connection connection = DriverManager.getConnection(url, user, password);
            Statement statement = connection.createStatement();
            String sql1 = "insert into demo(id,name,password,phone) values('5','赵四','1015','110')";
            String sql2 = "insert into demo(id,name,password,phone) values('6','王五','115015','119')";
            int row1 = statement.executeUpdate(sql1);
            System.out.println("影响了数据库" + "row" + "条数据");
            int row2 = statement.executeUpdate(sql2);
            System.out.println("影响了数据库" + "row" + "条数据");
            statement.close();
            connection.close();
        }catch (Exception e){
        throw new RuntimeException(e);
        }
    }
}


